<?php
require "admin_header.php";
?>
<script type="text/javascript" language="javascript">
	page=3;
</script>
<div class="heading">
    <a>lấy thông tin phim</a>
</div>
<div class="content_page">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<div class="ds">
<table style=" width:90%" border="0" class="tb_ltt" >
	<a href="admin_auto_add_viphim.php">Trang ViPhim.com</a>
    <form action="" method="post" enctype="multipart/form-data" name="link_form" id="link_form">
    <tr>
    	<td class="lb_ltt">Nhập Địa Chỉ URL:</td>
        <td>
        	<input name="link" type="text" placeholder=" Link phimsot " id="link">
	        <input name="submit" type="submit" value="Lấy Thông Tin" id="submit_link">
        </td>
    </tr>
    </form>

	<form action="admin_auto_add_process.php" method="post" enctype="multipart/form-data" name="info_form" id="info_form">
    
    <tr>
    	<td class="lb_ltt">Tên phim</td>
        <td><input name="ten" id="ten" type="text"  readonly="readonly" /></td>
    </tr>
    <tr>
    	<td class="lb_ltt">Hình Ảnh:</td>
    	<td width="230px"  valign="top" id="cot1">
        	<img id="img1" src="" /><br />
            <input name="img" id="img" type="text"  readonly="readonly" />
        </td>
    </tr>
   	<tr>
    	<td class="lb_ltt">Ảnh Thumbnail:</td>
        <td>
        	<img id="img2" src="" /><br />
            <input name="img_thumbnail" id="img_thumbnail" type="text" readonly="readonly" />
        </td>
    </tr>
    <tr>
    	<td class="lb_ltt">Đạo diễn</td>
        <td><input name="daodien" id="dd" type="text" readonly="readonly" /></td>
    </tr>
    <tr>
    	<td class="lb_ltt">Diễn viên</td>
        <td><input name="dienvien" type="text" id="dv" ></td>
    </tr>
    <tr>
    	<td class="lb_ltt">Nhà sản xuất </td>
        <td><input name="nsx" type="text" id="nsx"  readonly="readonly"></td>
    </tr>
    <tr>
    	<td class="lb_ltt">Quốc gia</td>
        <td><input name="qg" type="text" id="qg"  readonly="readonly"></td>
    </tr>
    <tr>
    	<td class="lb_ltt"> Thể loại</td>
        <td><input name="tl" type="text" id="tl"  readonly="readonly"></td>
    </tr>
    <tr>
    	<td class="lb_ltt">Thời lượng</td>
        <td><input name="time" type="text" id="time"  readonly="readonly"></td>
    </tr>
    <tr>
    	<td class="lb_ltt">Chất lượng</td>
        <td><input name="quality" type="text" id="quality" readonly="readonly"></td>
    </tr>
    <tr>
    	<td class="lb_ltt"> Chuyển ngữ</td>
        <td><input name="sub" type="text" id="sub" readonly="readonly"></td>
    </tr>
    <tr>
    	<td class="lb_ltt">Năm sản xuất</td>
        <td><input name="year" type="text" id="year" readonly="readonly"></td>
    </tr>
    <tr>
    	<td class="lb_ltt">Ngày đăng phim</td>
        <td><input name="day1" type="text" id="day1" readonly="readonly"></td>
    </tr>
    <tr>
    	<td class="lb_ltt">Ngày đăng tập mới</td>
        <td><input name="day2" type="text" id="day2" readonly="readonly"></td>
    </tr>
    <tr>
    	<td id="cot5" class="lb_ltt">Nội dung:</td>
        <td>
      		<textarea name="noidung" cols="50" rows="20" id="nd" readonly="readonly"></textarea>
       	</td>
    </tr>
   	<tr>
    	<td class="lb_ltt">Địa chỉ phim:</td>
        <td><input type="button" name="getembed" id="getembed" value="Lấy Địa Chỉ" disabled/></td>
    </tr>
    <tr>
    	<td></td>
    	<td  valign="top" id="cot3">
    	</td>
    </tr>
    
    <tr>
    	<td colspan="2" style="text-align:center"><input name="Button" type="button" value="Thêm Phim Vào" id="submit_info" disabled /></td>
    </tr>
</form>
</table>
</div>

<div id="phim" style="display:none">
</div>
<div id="loader" style="display:none">
</div>
<script type="text/javascript">
$.ajaxSetup ({  
        cache: false  
    });
	var ajax_load = "<img src='../img/load.gif' alt='loading...' />";  
$('#link_form').submit(function(e) {
	e.preventDefault(); // don't submit multiple times
	var lienket=$('#link').val();
	$("#loader").load("get_link.php .col1 > div","link="+lienket,function(){
		//img + load img
		$("#img").val($('.large_thumbnail > img').attr("src"));
		$("#img1").attr("src",$('.large_thumbnail > img').attr('src'));
		var last = $('.large_thumbnail > img').attr("src").substr(-4);
		var thumb = $('.large_thumbnail > img').attr("src").replace(last,"_thumbnail"+last);
		$("#img_thumbnail").val(thumb);
		$("#img2").attr("src",thumb);
		//link phim
		var lienket = $(".button_20px").attr("href");
		$("#phim").load("get_link.php .go_episode","link="+lienket,function(){
				var size =$("#phim > a").size();
				for(var i=1;i<=size;i++)
				{
					var hr = $("#phim > a:nth-child("+i+")").attr("href");
					var text = $("#phim > a:nth-child("+i+")").text();
					$('<div id="'+i+'" style="display:none"></div>').appendTo('#cot3');
					$('#'+i).load("get_link.php object","link="+hr,function(){
						});
						if(i==size)
						{
							$("#getembed").removeAttr("disabled");
						}
				};
			});
		
		//form thong tin
		$("#dd").val($('ul li:first').text().replace($('ul li:first > span').text().replace(/[\*\^\'\!]/g,''),""));
		$("#dv").val($('ul li:nth-child(2)').text().replace($('ul li:nth-child(2) > span').text().replace(/[\*\^\'\!]/g, ''),""));
		$("#nsx").val($('ul li:nth-child(3)').text().replace($('ul li:nth-child(3) > span').text().replace(/[\*\^\'\!]/g, ''),""));
		$("#qg").val($('ul li:nth-child(4)').text().replace($('ul li:nth-child(4) > span').text().replace(/[\*\^\'\!]/g, ''),""));
		$("#tl").val($('ul li:nth-child(5)').text().replace($('ul li:nth-child(5) > span').text().replace(/[\*\^\'\!]/g, ''),""));
		$("#time").val($('ul li:nth-child(6)').text().replace($('ul li:nth-child(6) > span').text().replace(/[\*\^\'\!]/g, ''),""));
		$("#quality").val($('ul li:nth-child(7)').text().replace($('ul li:nth-child(7) > span').text().replace(/[\*\^\'\!]/g, ''),""));
		$("#sub").val($('ul li:nth-child(8)').text().replace($('ul li:nth-child(8) > span').text().replace(/[\*\^\'\!]/g, ''),""));
		$("#year").val($('ul li:nth-child(9)').text().replace($('ul li:nth-child(9) > span').text().replace(/[\*\^\'\!]/g, ''),""));
		$("#day1").val($('ul li:nth-child(11)').text().replace($('ul li:nth-child(10) > span').text().replace('Ngày đăng phim: ', ''),""));
		$("#day2").val($('ul li:nth-child(12)').text().replace($('ul li:nth-child(11) > span').text().replace('Ngày đăng tập mới:', ''),""));
		$("#ten").val($('.ps_title_2').text());
		$("#nd").val($('.full').html());
		
		$("#submit_link").attr("disabled","disabled"); 
	});
	return false;
});
$('#getembed').click(function(e){	
	$('#getembed').attr("disabled","disabled");
	var size =$("#phim > a").size();
	for(var i=1;i<=size;i++)
	  {
		  if($('#'+i+' embed').attr('flashvars')!== null)
		  {
			var text = $("#phim > a:nth-child("+i+")").text();
		  	$('<div class=\'wr_hr\'><div class=\'text\'>Tập '+text+':</div><div class=\'ip_ltt\'><input name="phim[]" type="text" id="'+'input'+i+'" value="'+text+"+"+$('#'+i+' embed').attr('flashvars').replace('skin=http://phimsot.com/html/phimsotplayer/skins/whotube/whotube.xml&','')+'" /></div></div>').appendTo('#cot3');
		 	$('<div class=\'wr_hr\'><div class=\'text\'>Tập '+text+':</div><div class=\'ip_ltt\'><input name="phim[]" type="text" id="'+'input'+i+'" value="'+text+"+"+$('#'+i+' embed').attr('flashvars').replace('skin=http://phimsot.com/html/phimsotplayer/skins/whotube/whotube.xml&','')+'" /></div></div>').appendTo('#info_form');
		  }
	  };
	 $("#submit_info").removeAttr("disabled");
	});
$('#submit_info').click(function(e){
	$('#info_form').submit();
});
	
</script>
</div>
<?php
require "admin_footer.php";
?>